# create a new bodhi-backend system
#
# This group makes bodhi-backend servers.
# They are used by releng to push updates with bodhi. 
# They also run some misc releng scripts.
#

- include: "/srv/web/infra/ansible/playbooks/include/virt-create.yml myhosts=bodhi-backend:bodhi-backend-stg"

# Once the instance exists, configure it. 

- name: make bodhi-backend server system
  hosts: bodhi-backend:bodhi-backend-stg
  user: root
  gather_facts: True

  vars_files:
  - /srv/web/infra/ansible/vars/global.yml
  - "/srv/private/ansible/vars.yml"
  - /srv/web/infra/ansible/vars/{{ ansible_distribution }}.yml

  roles:
  - base
  - nagios_client
  - collectd/base
  - hosts
  - builder_repo
  - fas_client
  - sudo
  - rkhunter

  - role: nfs/client
    mnt_dir: '/pub/'
    nfs_src_dir: 'fedora_ftp/fedora.redhat.com/pub/'

  - role: nfs/client
    mnt_dir: '/mnt/fedora_koji'
    nfs_src_dir: 'fedora_koji'
    when: env != 'staging'

    # In staging, we mount fedora_koji as read only (see nfs_mount_opts)
  - role: nfs/client
    mnt_dir: '/mnt/fedora_koji_prod'
    nfs_src_dir: 'fedora_koji'
    when: env == 'staging'

  - bodhi2/backend
  - fedmsg/base
  - role: collectd/fedmsg-service
    process: fedmsg-hub
    user: masher

  tasks:
  - name: create secondary volume dir for stg bodhi
    file: dest=/mnt/koji/vol state=directory owner=apache group=apache mode=0755
    tags: bodhi
    when: env == 'staging'
  - name: create symlink for stg/prod secondary volume
    file: src=/mnt/fedora_koji_prod/koji dest=/mnt/koji/vol/prod state=link
    tags: bodhi
    when: env == 'staging'
  - include: "{{ tasks }}/2fa_client.yml"
  - include: "{{ tasks }}/yumrepos.yml"
  - include: "{{ tasks }}/motd.yml"

  handlers:
  - include: "{{ handlers }}/restart_services.yml"
